package net.ghsoft
{
	import flash.utils.setTimeout;
	
	import mx.collections.ArrayCollection;
	import mx.core.FlexGlobals;
	
	import spark.components.Label;

	public class AppGlobal
	{
		public static function get WebURL():String
		{
			var result :String = "";
			result = FlexGlobals.topLevelApplication.url; 
			return result;
		}
		
		private static var _CtlUSB:USBGlobal = null;
		public static function get CtlUSB():USBGlobal
		{
			if(_CtlUSB == null)
			{
				_CtlUSB = new USBGlobal();
			}
			return _CtlUSB;
		}
		
		
		private static var _arrNowShowTime:ArrayCollection = new ArrayCollection();
		private static var _arrNowShowDay:ArrayCollection = new ArrayCollection();
		private static var _BRunNowShowTime:Boolean = false;
		
		public static function SetShowTimeLable(value:Label):void
		{
			_arrNowShowTime.addItem(value);
			if(_BRunNowShowTime == false)
			{
				_BRunNowShowTime = true;
				RunNowShowTime();
			}
		}
		
		public static function SetShowDayLable(value:Label):void
		{
			_arrNowShowDay.addItem(value);
			if(_BRunNowShowTime == false)
			{
				_BRunNowShowTime = true;
				RunNowShowTime();
			}
		}
		
		private static function RunNowShowTime():void
		{
			var tDate:Date = new Date();//获取时间
			var strNowShowTime:String = ConvertGlobal.Time2SystemString(tDate); 
			var strNowShowDay:String = ConvertGlobal.Date2SystemString(tDate); 
			
			for(var indexTime:int = 0; indexTime < _arrNowShowTime.length; indexTime ++)
			{
				var lTime:Label = _arrNowShowTime[indexTime] as Label;
				if(lTime != null)
				{
					lTime.text = strNowShowTime;
				}
			}
			
			for(var indexDay:int = 0; indexDay < _arrNowShowDay.length; indexDay ++)
			{
				var lDay:Label = _arrNowShowDay[indexDay] as Label;
				if(lDay != null)
				{
					lDay.text = strNowShowDay;
				}
			}
			
			setTimeout(RunNowShowTime, 1000);
		}
	}
}